﻿package{
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.display.Shape;
	import flash.events.MouseEvent;
	import flash.display.SimpleButton;
	public class myButton extends Sprite{
		private var _label:TextField;
		private var _label2:TextField;
		private var _labelName:String;
		private var tf:TextFormat;
		private var bg:Sprite;
		private var out:Sprite;
		private var button:SimpleButton;
		private var clicked:Boolean;
		public function myButton(s:String,w:Number,h:Number){
			this.clicked=false;
			this.bg=new Sprite();
			this.out=new Sprite();
			tf = new TextFormat();
			tf.font="Verdana";
			tf.color=0x000000;
			tf.size=12;
			tf.align="center";
			this._label=new TextField();
			
			_label.x=-8;
			_label.y=6;
			_label.scaleY=1;
			_label.scaleX=1;
			_label.width=w;
			_label.height=h;
			_label.selectable=false;
			
			//_label.autoSize="right";
			_label.text=s;
			_label.setTextFormat(tf);
			
			this._label2=new TextField();
			
			_label2.x=-8;
			_label2.y=6;
			_label2.scaleY=1;
			_label2.scaleX=1;
			_label2.width=w;
			_label2.height=h;
			_label2.selectable=false;
			
			//_label.autoSize="right";
			_label2.text=s;
			_label2.setTextFormat(tf);
			this.bg.graphics.lineStyle(1,0xdddddd);
			this.bg.graphics.beginFill(0xdddddd);
			this.bg.graphics.drawRoundRect(0,0,w,h,15,15);
			this.bg.graphics.endFill();
			this.bg.addChild(_label);
			this.out.graphics.lineStyle(1,0xffffff);
			this.out.graphics.beginFill(0xffffff);
			this.out.graphics.drawRoundRect(0,0,w,h,15,15);
			this.out.graphics.endFill();
			this.out.addChild(_label2);
			
			this.button=new SimpleButton();
			button.overState=bg;
			button.downState=out;
			button.hitTestState=bg;
			button.upState=out;
			button.useHandCursor=true;
			button.width=w;
			button.height=h;
			button.scaleX=1;
			button.scaleY=1;
			addChild(button);
			}
		public function disableStyleChange(){
			button.downState=bg;
			button.upState=bg;
			this.clicked=true;
			
			}
		public function enableStyleChange(){
			this.clicked=false;
			button.downState=out;
			button.upState=out;
			
			}
		
		public function getClicked():Boolean{
			
			return this.clicked;
			}
		public function resetClicked(){
			this.clicked=false;
			}
	}



}